<?php if (!defined('SERVER_ROOT')) { exit('No direct script access allowed');}
$this->template->title = 'Hệ thống hỗ trợ công tác quản lý cán bộ trường ĐHTG';
$v_pop_win = isset($_REQUEST['pop_win']) ? '_pop_win' : '';
$this->template->display('dsp_header' . $v_pop_win . '.php');
?>
<form name="frmMain" method="post" id="frmMain" action=""><?php
    echo $this->hidden('controller', $this->get_controller_url());
    echo $this->hidden('hdn_dsp_single_method', 'dsp_single_loaidonvi');
    echo $this->hidden('hdn_dsp_all_method', 'dsp_all_loaidonvi');
    echo $this->hidden('hdn_update_method', 'update_loaidonvi');
    echo $this->hidden('hdn_delete_method', 'delete_loaidonvi');
    echo $this->hidden('pop_win', $v_pop_win);
    echo $this->hidden('hdn_item_id', $var_maloaidonvi);
    echo $this->hidden('hdn_phan_lvxl', '');
    ?>
    <h2 style="text-align: center"><?php echo $var_tenloaidonvi; ?></h2>
    <div class="Row" id="div_phan_lvxl">
          <table style="background-color: #FFFFFF" width="100%" class="adminlist" cellspacing="0" border="1" id="tbl_user_in_group">
                <colgroup>
                    <col width="10%" />
                    <col width="90%" />

                </colgroup>
                <tr>
                    <th>All</th>
                    <th>Tên lĩnh vực</th>
                </tr>
                <?php while ($arr = $arr_all_linhvucxuly->FetchRow()): ?>
                <?php
                $MA_LINH_VUC_THU_TUC  = $arr['MA_LINH_VUC_THU_TUC'];
                $TEN_LINH_VUC_THU_TUC = $arr['TEN_LINH_VUC_THU_TUC'];
                $CHECKED = $arr['CHECKED'];
                ?>
                    <tr id="tr_<?php echo $MA_LINH_VUC_THU_TUC; ?>">
                        <td class="center">
                            <input type="checkbox"
                                   name="chk_group"
                                   value="<?php echo $MA_LINH_VUC_THU_TUC; ?>"
                                   id="<?php echo $MA_LINH_VUC_THU_TUC; ?>"
                                   <?php if ($CHECKED == 1): ?>
                                       checked
                                   <?php endif; ?>
                                   />
                        </td>
                        <td>
                            <label for="<?php echo $MA_LINH_VUC_THU_TUC; ?>"><?php echo $TEN_LINH_VUC_THU_TUC; ?></label>
                        </td>
                    </tr>
            <?php endwhile; ?>
            </table>
    </div>
    <div class="button-area">
        <input type="button" name="update" class = 'button save' value="Cập nhật" onclick="btn_update_lvxl_onclick();"/>
        <?php $v_back_action = ($v_pop_win === '') ? 'btn_back_onclick();' : 'try{window.parent.hidePopWin();}catch(e){window.close();};';?>
        <input type="button" name="cancel" class = 'button close' value="Bỏ qua" onclick="<?php echo $v_back_action;?>"/>
    </div>

</form>
<script type="text/javascript">
function btn_update_lvxl_onclick()
    {
        var q = "#div_phan_lvxl input[type='checkbox']";
        var arr_checked_lvxl = new Array();
        $(q).each(function(index) {
            if ($(this).is(':checked'))
            {
                arr_checked_lvxl.push($(this).attr('id'));
            }
        });

        $('#hdn_phan_lvxl').val(arr_checked_lvxl.join());

        var f = document.frmMain;
        m = $("#controller").val() + 'update_linhvucxuly/0/';
        //alert(m) ;
        var xObj = new DynamicFormHelper('','',f);
        if (xObj.ValidateForm(f)){
            $("#frmMain").attr("action", m);
            f.submit();
        }
}
</script>
<?php $this->template->display('dsp_footer' .$v_pop_win . '.php');